package com.quasar.hpatient.presenter;
import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.DailyRecordDetailsData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OndailyRecordListener;
/**
 * author : 许建宏
 * Date: 2017/11/20 0020
 * View:
 */

public class DailyRecordPresenter {


    private RequestModel requestModel;
    private OndailyRecordListener listener;

    public DailyRecordPresenter(OndailyRecordListener listener) {
        this.requestModel = new RequestModel();
        this.listener = listener;
    }

    //获取一天中某项的日常记录
    public void GetUserOneDayDailyRecordData(String itemId,String dayTime,String type){

        requestModel.GetUserOneDayDailyRecordData(itemId, dayTime,type, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                listener.onDailyRecordDetailsSuccess(data);
            }

            @Override
            public void onError(String msg) {
                listener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                listener.onRefreshUI();
            }
        });
    }

    //提交某项日常记录检查信息
    public void AddDailyRecordDetailData(String logValue,String logTime,String markValue,String paired,String dailyitemName,String dailyitemDose,String warn){
        requestModel.AddDailyRecordDetailData(
                logValue,
                logTime,
                markValue,
                paired,
                dailyitemName,
                dailyitemDose,warn, new AnotherResultListener<DataStateResult>() {
                    @Override
                    public void onSuccess(DataStateResult data) {
                        listener.onSubmitSuccess(data);
                    }

                    @Override
                    public void onError(String msg) {
                        listener.onError(msg);
                    }

                    @Override
                    public void onRefreshUI() {
                        listener.onRefreshUI();
                    }
                });
    }

    //修改日常检查项目
    public void updateAloneItemDailyRecordDetail(String id,String logValue,String paired,String markValue,String type,String warn,String indexId){

        requestModel.updateAloneItemDailyRecordDetailData(id, logValue, paired, markValue,type,warn,indexId, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                listener.onUpdateValueSuccess(data);
            }

            @Override
            public void onError(String msg) {
                listener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                listener.onRefreshUI();
            }
        });
    }



}
